@<template>
  <div class="toast" v-if="isShow">
      <span>{{message}}</span>
  </div>
</template>

<script>
export default {
    data() {
        return {
            message: '',
            isShow: false,
        }
    },
    methods: {
        show(message, delay=1500) {
            this.message = message;
            this.isShow = true;
            setTimeout(() => {
                this.message = ''
                this.isShow = false
            }, delay);
        }
    }
}
</script>

<style scoped>
.toast {
    position: absolute;
    /* width: 100px; */
    padding: 10px 20px;
    border-radius: 15px;
    height: 30px;
    line-height: 30px;
    background-color: rgba(0,0,0,.5);
    color: #fff;
    z-index: 4;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    transition: all 1s;
}
</style>